

#pragma once

#include "DHD_Messages.h"
#include <queue>
using std::queue;



typedef void (*MESSAGEPROC)(CBaseMessage*);



class DHD_MessageSystem
{
private:
	queue<CBaseMessage*>			m_MsgQueue;				//	Stores my messages.
	MESSAGEPROC						m_pMsgProc;			//	Points to user defined function.

	DHD_MessageSystem() { m_pMsgProc = NULL;	}
	DHD_MessageSystem(const DHD_MessageSystem&);
	DHD_MessageSystem& operator=(const DHD_MessageSystem&);

	~DHD_MessageSystem() {}

public:
	
	static DHD_MessageSystem* GetInstance(void);

	//	How many messages waiting to be processed.
	inline int GetNumMessages(void) { return (int)m_MsgQueue.size(); }

	//	Setup the function pointer for our messages.
	void InitMessageSystem(MESSAGEPROC MsgProc);

	//	Sends the message into the queue and awaits processing later on through
	//	The ProcessMessages() function.
	void SendMsg(CBaseMessage* pMsg);

	//	Processes all the messages that are waiting inside of the queue.
	//	Normally you only call this function once per frame.
	void ProcessMessages(void);

	//	Clears any messages that may be remaining
	void ClearMessages(void);

	//	Clears any messages that may be remaining and sets the function pointer to NULL.
	void ShutdownMessageSystem(void);
};